package com.itheima.a02test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Test1 {
    public static void main(String[] args) {
        //定义集合 添加整数 1 2 3 4 5 6 7 8 9 10
        //过滤掉计数 留下偶数
        ArrayList<Integer> list=new ArrayList<>();

        //添加数据
        Collections.addAll(list,1,2,3,4,5,6,7,8,9,10);

        //进行数据的过滤
        //list.stream().filter(s->s % 2 == 0).forEach(s-> System.out.println(s));
        
        //将数据添加到另一个集合
        List<Integer> list1 = list.stream().filter(s -> s % 2 == 0)
                .collect(Collectors.toList());
        System.out.println(list1);

    }
}
